<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        function factorial(n) {
            console.trace();
            if(n === 1 || n === 0) { // 基线条件
                return 1;
            }
            
            return n * factorial(n - 1); // 递归调用
        }
        console.log(factorial(5));	// 120
    </script>
</body>
</html>